{% extends 'admin-v2/layout.html.twig' %}

{% set script_controller = 'coupon/query' %}

{% set menu = 'admin_v2_marketing_coupon_query' %}

{% block main %}
  {{ web_macro.flash_messages() }}

  <form id="coupon-search-form" class="form-inline well well-sm" action="" method="get" novalidate>
    <div class="form-group">
      <select class="form-control" name="status">
        {{ select_options(dict('couponStatus'), app.request.query.get('status'), 'coupon.query.by_status'|trans) }}
      </select>
    </div>
    <div class="form-group">
      <select class="form-control" name="type">
        {{ select_options(dict('couponType'), app.request.query.get('type'), 'coupon.query.by_type'|trans) }}
      </select>
    </div>
    <div class="form-group">
      <input type="text" id="useStartDateTime" value="{{ app.request.query.get('useStartDateTime') }}" name="useStartDateTime" class="form-control" placeholder="{{ 'coupon.query.by_use_start_date'|trans }}" styuseStartDateTimele="width:150px;">
    </div>
    <div class="form-group">
      <input type="text" id="useEndDateTime" value="{{ app.request.query.get('useEndDateTime') }}" name="useEndDateTime" class="form-control" placeholder="{{ 'coupon.query.by_use_end_date'|trans }}" style="width:150px;">
    </div>
    <div class="form-group">
      <input class="form-control" type="text" placeholder="{{ 'coupon.code'|trans }}" name="code" value="{{ app.request.get('code') }}">
    </div>
    <button class="btn btn-primary">{{ 'form.btn.search'|trans }}</button>

    <a class="btn btn-primary mhs" href="{{ path('admin_v2_coupon_export', {
      status: app.request.query.get('status'),
      type: app.request.query.get('type'),
      useStartDateTime: app.request.query.get('useStartDateTime'),
      useEndDateTime: app.request.query.get('useEndDateTime'),
      code: app.request.query.get('code'),
    }) }}">{{ 'plugin.admin.user.manage.form.user_export_btn'|trans }}</a>
  </form>

  <table class="table table-striped" id="coupon-list">
    <thead>
    <tr>
      <th style="width:10%">{{ 'coupon.id'|trans }}</th>
      <th style="width:10%">{{ 'coupon.code'|trans }}</th>
      <th style="width:5%">{{ 'coupon.target_type'|trans }}</th>
      <th style="width:10%">{{ 'coupon.status'|trans }}</th>
      <th style="width:7%">{{ 'coupon.user'|trans }}</th>
      <th>{{ 'coupon.order'|trans }}</th>
      <th>{{ 'coupon.content'|trans }}</th>
      <th style="width:5%">{{ 'coupon.origin_price'|trans }}</th>
      <th style="width:5%">{{ 'coupon.pay_amount'|trans }}</th>
      <th style="width:10%">{{ 'coupon.batch.name'|trans }}</th>
      <th>{{ 'coupon.receive_time'|trans }}</th>
      <th>{{ 'coupon.used_time'|trans }}</th>
    </tr>
    </thead>
    <tbody>
    {% for coupon in coupons %}
      {% set order = orders[coupon.orderId]|default(null) %}
      {% set batch = batchs[coupon.batchId]|default(null) %}
      {% set user = users[coupon.userId]|default(null) %}
      {% include 'admin-v2/marketing/coupon/coupon-tr.html.twig' %}
    {% else %}
      <tr class="empty">
        <td colspan="20">{{ 'coupon.no_coupon_tip'|trans }}</td>
      </tr>
    {% endfor %}
    </tbody>
  </table>
  {{ web_macro.paginator(paginator) }}

{% endblock %}
